package design.simdi.code.final_paper.utils;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

import design.simdi.code.final_paper.site.panels.PagePanel;

/**
 * 
 * @author Marius Dumitriu - (Jun 8, 2010 - 12:49:54 AM)
 * 
 * @param <PagePanel>
 */
public class PanelFactory {

	@SuppressWarnings("unchecked")
	public static PagePanel createPageContent(Class<? extends PagePanel> clazz, String id) {
		try {
			Constructor c = clazz.getConstructor(new Class[] { String.class });
			PagePanel panel = (PagePanel) c.newInstance(new Object[] { new String(id) });

			return panel;

		} catch (InstantiationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SecurityException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

}
